package com.ruoyi.mk.service.impl;

import java.util.List;

import com.ruoyi.mk.domain.MKFreight;
import com.ruoyi.mk.mapper.MkFreightMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mk.mapper.MkCategoryMapper;
import com.ruoyi.mk.domain.MkCategory;
import com.ruoyi.mk.service.IMkCategoryService;

/**
 * 南疆东线品类查询Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-04
 */
@Service
public class MkCategoryServiceImpl implements IMkCategoryService {

    @Autowired
    private MkCategoryMapper mkCategoryMapper;

    /**
     * 查询南疆东线品类查询
     * 
     * @param id 南疆东线品类查询主键
     * @return 南疆东线品类查询
     */
    @Override
    public MkCategory selectMkCategoryById(Long id)
    {
        return mkCategoryMapper.selectMkCategoryById(id);
    }

    /**
     * 查询南疆东线品类查询列表
     * 
     * @param mkCategory 南疆东线品类查询
     * @return 南疆东线品类查询
     */
    @Override
    public List<MkCategory> selectMkCategoryList(MkCategory mkCategory)
    {
//        MKFreight mkFreight = new MKFreight();
//        mkFreight.setDictionaryAttribution(mkCategory.getMkDictionaryAttribution());
//        mkFreight.setDensity(mkCategory.getDensity());
//        mkFreight = mkFreightMapper.getFreight(mkFreight);
//        List<MkCategory> mkCategories = mkCategoryMapper.selectMkCategoryList(mkCategory);
//        for (MkCategory mkCategory1 : mkCategories) {
//            mkCategory1.setPrice(mkFreight.getPrice());
//        }
//        return mkCategories;
        return mkCategoryMapper.selectMkCategoryList(mkCategory);
    }

    /**
     * 新增南疆东线品类查询
     * 
     * @param mkCategory 南疆东线品类查询
     * @return 结果
     */
    @Override
    public int insertMkCategory(MkCategory mkCategory)
    {
        return mkCategoryMapper.insertMkCategory(mkCategory);
    }

    /**
     * 修改南疆东线品类查询
     * 
     * @param mkCategory 南疆东线品类查询
     * @return 结果
     */
    @Override
    public int updateMkCategory(MkCategory mkCategory)
    {
        return mkCategoryMapper.updateMkCategory(mkCategory);
    }

    /**
     * 批量删除南疆东线品类查询
     * 
     * @param ids 需要删除的南疆东线品类查询主键
     * @return 结果
     */
    @Override
    public int deleteMkCategoryByIds(Long[] ids)
    {
        return mkCategoryMapper.deleteMkCategoryByIds(ids);
    }

    /**
     * 删除南疆东线品类查询信息
     * 
     * @param id 南疆东线品类查询主键
     * @return 结果
     */
    @Override
    public int deleteMkCategoryById(Long id)
    {
        return mkCategoryMapper.deleteMkCategoryById(id);
    }

    @Override
    public Long getViewsCount() {
        Long count = 0L;
        Integer flag = mkCategoryMapper.updateCount();
        if (flag > 0) {
            count = mkCategoryMapper.getViewsCount();
        }else {
            throw new RuntimeException("记录用户浏览次数失败!");
        }
        return count;
    }

}
